package com.luban.importdemo;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

/**
 * @Author: lijunwei
 * @Time: 2021/5/10 16:11
 */
public class UserBeanDefinitionRegister implements ImportBeanDefinitionRegistrar {

	@Override
	public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
										BeanDefinitionRegistry registry) {
		//创建一个bean定义对象
		RootBeanDefinition rootBeanDefinition = new RootBeanDefinition(Cat.class);
		//把bean定义对象导入到容器中
		registry.registerBeanDefinition("cat",rootBeanDefinition);
	}
}
